package com.mentaleye.biz.impl;

import com.mentaleye.bean.CompanyStudentBean;
import com.mentaleye.bean.ReturnVisitBean;
import com.mentaleye.biz.CompanyStudentBiz;
import com.mentaleye.biz.ReturnVisitBiz;
import com.mentaleye.service.ReturnVisitService;
import com.mentaleye.util.CommonResult;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by Rock on 2017/5/23.
 */

@Service
public class ReturnVisitBizImpl implements ReturnVisitBiz{

    private static Logger logger = Logger.getLogger(ReturnVisitBizImpl.class);

    @Autowired private CompanyStudentBiz compantStudentBiz;
    @Autowired private ReturnVisitService returnVisitService;

    public CommonResult add(ReturnVisitBean bean){
        CommonResult result = new CommonResult();
        boolean success = false;
        try{
            success = returnVisitService.add(bean);
            result.setIsSuccess(success);
        }catch (Exception e){
            logger.error("添加回访记录异常",e);
        }
        return result;
    }

    public CommonResult editRelation(ReturnVisitBean bean,boolean isAdd){
        CommonResult result = null;
        try{
            CompanyStudentBean companyStudentBean = new CompanyStudentBean();
            companyStudentBean.setCompanyId(bean.getCompanyId());
            companyStudentBean.setReturnVisitId(bean.getReturnVisitId());
            companyStudentBean.setWorkState(bean.getWorkState());
            result = compantStudentBiz.edit(companyStudentBean,isAdd);
        }catch (Exception e){
            logger.error("编辑关联异常",e);
        }
        return result;
    }
}
